<?php
if (in_array(count(get_included_files()), ['1'])) {
if (strcmp(php_sapi_name(), 'cli')) {
printf('Use php-cli to run the challenge!\n');
} else {
printf(gzinflate(base64_decode('1dTBDYAgDAXQe6fgaC8O4DDdfwyhVGmhbaKe/BfQfF8gAQFKz8aRh0JEJY0qIIenINTBEY3qNNVUAfuXzIGitJVqpiBa4yp2U8ZKtKmANzewbaqG2lrAGbNWslOvgD52lULNLfgY9ZiZtdxCsLJ3+Q/2RVuOxji0jyl9aJfrZLJzxhgtS65TWS66wdr7fYzRFtvc/wU9Wpn6BQGc')));
define('F', readline('Flag: '));
if (strcmp(strlen(constant('F')), '41')) {
printf('Nope!\n');
} else {
if (in_array(substr(constant('F'), 0, 5), ['crew{'])) {
if (strstr(strrev(crc32(substr(constant('F'), 5, 4))), '7607349263')) {
if (strncmp('A'.'\x1b'.'/'.'k',substr(constant('F'),'5','4')^substr(constant('F'),'9','4'))) {
printf('Nope xor!\n');
} else {
srand(31337);
define('D', openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr(constant('F'), 0, 16), 2, pack('C4', rand(), rand(), rand(), rand())));
if (in_array(array_sum([ctype_print(constant('D')), strpos(substr(constant('F'), 15, 17), constant('D'))]), ['2'])) {
if (strcmp(base64_encode(hash('sha256', substr(constant('F'), 0, 32))^substr(constant('F'), 32)), 'BwdRVwUHBQVF')) {
printf('Nope!\n');
} else {
printf('Congratulations, this is the right flag!\n');
}
} else {
printf('Nope!\n');
}
}
} else {
printf('Nope!\n');
}
} else {
printf('Nope!\n');
}
}
}
} else {
printf('Nope!\n');
} (edited)crew{srand(31337);
define('D', openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr(constant('F'), 0, 16), 2, pack('C4', rand(), rand(), rand(), rand())));
if (in_array(array_sum([ctype_print(constant('D')), strpos(substr(constant('F'), 15, 17), constant('D'))]), ['2'])) {
if (mstrcmp(base64_encode(hash('sha256', substr(constant('F'), 0, 32))^substr(constant('F'), 32)), 'BwdRVwUHBQVF')) {
printf('Nope!\n');
} else {
printf('Congratulations, this is the right flag!\n');
}
} else {
printf('Nope!\n');
}<?php
if (in_array(count(get_included_files()), ['1'])) {
if (strcmp(php_sapi_name(), 'cli')) {
printf('Use php-cli to run the challenge!\n');
} else {
printf(gzinflate(base64_decode('1dTBDYAgDAXQe6fgaC8O4DDdfwyhVGmhbaKe/BfQfF8gAQFKz8aRh0JEJY0qIIenINTBEY3qNNVUAfuXzIGitJVqpiBa4yp2U8ZKtKmANzewbaqG2lrAGbNWslOvgD52lULNLfgY9ZiZtdxCsLJ3+Q/2RVuOxji0jyl9aJfrZLJzxhgtS65TWS66wdr7fYzRFtvc/wU9Wpn6BQGc')));
define('F', readline('Flag: '));
if (strcmp(strlen(constant('F')), '41')) {
printf('Nope!\n');
} else {
if (in_array(substr(constant('F'), 0, 5), ['crew{'])) {
if (strstr(strrev(crc32(substr(constant('F'), 5, 4))), '7607349263')) {
if (strncmp('A'.'\x1b'.'/'.'k',substr(constant('F'),'5','4')^substr(constant('F'),'9','4'))) {
printf('Nope xor!\n');
} else {
srand(31337);
define('D', openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr(constant('F'), 0, 16), 2, pack('C4', rand(), rand(), rand(), rand())));
if (in_array(array_sum([ctype_print(constant('D')), strpos(substr(constant('F'), 15, 17), constant('D'))]), ['2'])) {
if (strcmp(base64_encode(hash('sha256', substr(constant('F'), 0, 32))^substr(constant('F'), 32)), 'BwdRVwUHBQVF')) {
printf('Nope!\n');
} else {
printf('Congratulations, this is the right flag!\n');
}
} else {
printf('Nope!\n');
}
}
} else {
printf('Nope!\n');
}
} else {
printf('Nope!\n');
}
}
}
} else {
printf('Nope!\n');
} (edited)srand(31337);
define('D', openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr(constant('F'), 0, 16), 2, pack('C4', rand(), rand(), rand(), rand())));
if (in_array(array_sum([ctype_print(constant('D')),strpos(substr(constant('F'), 15, 17), constant('D'))]), ['2']))<?php
if (in_array(count(get_included_files()), ['1'])) {
if (strcmp(php_sapi_name(), 'cli')) {
printf('Use php-cli to run the challenge!\n');
} else {
printf(gzinflate(base64_decode('1dTBDYAgDAXQe6fgaC8O4DDdfwyhVGmhbaKe/BfQfF8gAQFKz8aRh0JEJY0qIIenINTBEY3qNNVUAfuXzIGitJVqpiBa4yp2U8ZKtKmANzewbaqG2lrAGbNWslOvgD52lULNLfgY9ZiZtdxCsLJ3+Q/2RVuOxji0jyl9aJfrZLJzxhgtS65TWS66wdr7fYzRFtvc/wU9Wpn6BQGc')));
define('F', readline('Flag: '));
if (strcmp(strlen(constant('F')), '41')) {
printf('Nope!\n');
} else {
if (in_array(substr(constant('F'), 0, 5), ['crew{'])) {
if (strstr(strrev(crc32(substr(constant('F'), 5, 4))), '7607349263')) {
if (strncmp('A'.'\x1b'.'/'.'k',substr(constant('F'),'5','4')^substr(constant('F'),'9','4'))) {
printf('Nope xor!\n');
} else {
srand(31337);
define('D', openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr(constant('F'), 0, 16), 2, pack('C4', rand(), rand(), rand(), rand())));
if (in_array(array_sum([ctype_print(constant('D')), strpos(substr(constant('F'), 15, 17), constant('D'))]), ['2'])) {
if (strcmp(base64_encode(hash('sha256', substr(constant('F'), 0, 32))^substr(constant('F'), 32)), 'BwdRVwUHBQVF')) {
printf('Nope!\n');
} else {
printf('Congratulations, this is the right flag!\n');
}
} else {
printf('Nope!\n');
}
}
} else {
printf('Nope!\n');
}
} else {
printf('Nope!\n');
}
}
}
} else {
printf('Nope!\n');
} (edited)1550165595, 1550165595, 2075415819, 700108414encrypted_string = 'wCX3NcMho0BZO0SxG2kHxA==' # Encrypted string
encrypted_bytes = base64.b64decode(encrypted_string)
key = 'YOUR_KEY_HERE' # 16-byte key
iv = bytes([0x5b,0xf,0xb,0x7e])
known = b"crew{php_1s_4"
found = False
for byte1 in printable_ascii:
for byte2 in printable_ascii:
for byte3 in printable_ascii:
data = (byte1+byte2+byte3).encode()
cipher = AES.new(known+data,AES.MODE_CBC,iv+b'\x00'*12)
decrypted_data = cipher.decrypt(encrypted_bytes)
## count printable ascii in decrypted data
count = 0
for x in decrypted_data:
if 32<=x<=126:
count+=1
print(count)
if found:
break
if found:
breakif (in_array(array_sum([ctype_print(constant('D')), strpos(substr($F, 15, 17), constant('D'))]), ['2'])) {
echo 'here';
}ctype_print(constant('D')) and strpos(substr($F, 15, 17), constant('D')) have to equal 2substr($F, 15, 17) will overlap with 3 bytes we brute force, right?flag[16:16+16], right?<?php
# turn off openssl_decrypt warnings
error_reporting(E_ERROR | E_PARSE);
$F_orig = 'crew{php_1s_4';
for ($i = 0; $i <= 255; $i++) {
for ($j = 0; $j <= 255; $j++) {
for ($k = 0; $k <= 255; $k++) {
$byte1 = chr($i);
$byte2 = chr($j);
$byte3 = chr($k);
$F = $F_orig . $byte1 . $byte2 . $byte3;
#echo $F . "\n"; # looks good
#echo strlen($F) . "\n"; # always 16
# this will reseed each loop
srand(31337);
$D = openssl_decrypt('wCX3NcMho0BZO0SxG2kHxA==','aes-128-cbc', substr($F, 0, 16), 2, pack('C4', rand(), rand(), rand(), rand()));
if (in_array(array_sum([ctype_print($D), strpos(substr($F, 15, 17), $D)]), ['2'])) {
echo 'here';
}
}
}
}if (strcmp(strlen(constant('F')), '41')) {
printf('Nope!\n');
}'L*' instead of 'C4''5' instead of '\x1b'crew{php_1s_4_l4ngu4ge_0fm4g1c}?crew{php_1s_4_l4ngu4ge_0f_m4g1c_}crew{php_1s_4_l4ngu4ge_0f_m4g1c_} is 33?crew{php_1s_4_l4ngu4ge_0f_m4g1c_if (mstrcmp(base64_encode(hash('sha256', substr(constant('F'), 0, 32))^substr(constant('F'), 32)), 'BwdRVwUHBQVF'))Key = 32: 55ce7577w
Key = 33: 44bd6466v
Key = 34: 33ec1311q
Key = 35: 22db0200pcrew{php_1s_4_l4ngu4ge_0f_m4g1c_5b0e7b6a}known = "crew{php_1s_4_l4ngu4ge_0f_m4g1c_"
import hashlib
import base64
b64 = base64.b64decode(b"BwdRVwUHBQVF")
h = hashlib.sha256(known.encode()).hexdigest()
print(h)
print(b64)
print(len(b64))
out = ""
for i,j in zip(h,b64):
out += chr(ord(i)^j)
print(out)